package com.zzyl;

import cn.hutool.http.HttpResponse;
import cn.hutool.http.HttpUtil;
import cn.hutool.http.Method;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson2.JSON;

import java.util.HashMap;

public class HttpClientTest {
    public static void main(String[] args) {
//        String s = HttpUtil.get("https://www.baidu.com");
//        System.out.println(s);
        GetTest();//get请求
        PostTest();//post请求

    }
    private static void GetTest(){
        HashMap<String, Object> stringObjectHashMap = new HashMap<>();
        stringObjectHashMap.put("pageNum", 1);
        stringObjectHashMap.put("pageSize", 10);
        HttpResponse response = HttpUtil.createRequest(Method.GET, "http://192.168.100.168:9000/nursing/checkIn/list")
                .form(JSONUtil.toJsonStr(stringObjectHashMap))
                .header("authorization", "Bearer eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6IjA2MTljYzQxLTQ3NWQtNGYxNC05Yzc4LTYzY2I5ZTc0Yzg0YSJ9.dVl0TBkAAYsHznSTJU7TOv5uwW0eAVxnAvZV9VcLK9yiCg7KxDOIIxHDcwqAJSlyYboru5ZlpHjp3rgPUMxjaA")
                .execute();
        if (response.isOk()) {
            System.out.println(response.body());
        }

    }
    private static void PostTest(){
        HashMap<String, Object> stringObjectHashMap = new HashMap<>();
        stringObjectHashMap.put("pageNum", 1);
        stringObjectHashMap.put("pageSize", 10);
        HttpResponse response = HttpUtil.createRequest(Method.GET, "http://192.168.100.168:9000/nursing/checkIn/list")
                .body(JSONUtil.toJsonStr(stringObjectHashMap))
                .header("authorization", "Bearer eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6IjA2MTljYzQxLTQ3NWQtNGYxNC05Yzc4LTYzY2I5ZTc0Yzg0YSJ9.dVl0TBkAAYsHznSTJU7TOv5uwW0eAVxnAvZV9VcLK9yiCg7KxDOIIxHDcwqAJSlyYboru5ZlpHjp3rgPUMxjaA")
                .execute();
        if (response.isOk()) {
            System.out.println(response.body());
        }

    }
}
